package com.itboye.ihomebank.net;

import android.util.Log;

import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.base.MyApplcation;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.util.SPUtils;

public class BaseSuccessReqListener<T> extends XRequestListener<T>{
	
	public static String SUCCESS = "0";
	private ICompleteListener listener;
	private boolean isLock=false;
	public BaseSuccessReqListener(ICompleteListener listener){
		this.listener = listener;
	}

	public BaseSuccessReqListener(ICompleteListener listener,boolean isLock){
		this.listener = listener;
		this.isLock=isLock;
	}
	@Override
	public void onResponse(T resp) {
		Log.v("resp", resp.getClass().getName());
		if (!isLock){ //是否 是锁接口
			//服务器成功 切换到主服务器上
			SPUtils.put(MyApplcation.ctx,null, SPContants.ISLOCK,false);
			SPUtils.put(MyApplcation.ctx,null,SPContants.LOCK_SESSION,"");
		}
		if(listener != null){
			ResultEntity result = new ResultEntity(SUCCESS, "请求成功", resp);
			listener.success(result);
		}
	}

}
